import java.util.Scanner;

public class MaxPlusBonus {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("=== 最大值比较 & 加分运算（输入 q 退出）===");

        while (true) {
            /* ---------- 1. 读入一组整数 ---------- */
            System.out.print("请输入若干整数，用空格分隔：");
            String line = sc.nextLine().trim();
            if ("q".equalsIgnoreCase(line)) {
                System.out.println("Bye~");
                break;
            }
            if (line.isEmpty()) continue;

            String[] nums = line.split("\\s+");
            int max = Integer.MIN_VALUE;
            boolean valid = true;
            for (String n : nums) {
                try {
                    int val = Integer.parseInt(n);
                    if (val > max) max = val;
                } catch (NumberFormatException e) {
                    System.out.println("非法数字：" + n);
                    valid = false;
                    break;
                }
            }
            if (!valid) continue;          // 出错了，重新来
            System.out.println("最大值 = " + max);

            /* ---------- 2. 读入加分值 ---------- */
            System.out.print("请输入加分值：");
            line = sc.nextLine().trim();
            if ("q".equalsIgnoreCase(line)) {
                System.out.println("Bye~");
                break;
            }
            try {
                int bonus = Integer.parseInt(line);
                int result = max + bonus;
                System.out.println("最终结果（最大值 + 加分）= " + result);
            } catch (NumberFormatException e) {
                System.out.println("加分值必须是整数！");
            }
        }
        sc.close();
    }

return 0;

}